import numpy as np
from matplotlib import pyplot as plt 2024-02-04
Numpy
Numpy is the de facto library for numerical computing in Python.
Provides an efficient multi-dimensional array data structure that facilitates a wide variety of numerical computing tasks.
Provides a wide range of functions for array manipulation and core numerical functions that are important for many numerical tasks in mathematics, statistics and machine learning, bioinformatics, etc.
Basis for many other packages
Matplotlib
Matplot is the de facto library for plotting in Python.
matplotlib.pyplotNumpy: key concepts
Numpy arrays (type: ndarray) are multi-dimensional, ordered, and homogenous
Arrays have a data type (dtype) which specifies the types of the data they hold. You can leave this up to numpy to infer/guess, or you can specify dtype explicitly
Arrays have a size, dimension, and shape
Array access is a logical extension of indexing for other Python data structures like lists but there are some subtleties to be aware of
Many Numpy operators and functions are vectorized and are applied to every element in an input array
Numpy array creation and dimensional attributes
Note the subtle difference here between the arrays assigned to a and c:
Array’s don’t have to contain numbers:
array([[[ 1, 2, 3, 4]],
[[ 5, 6, 7, 8]],
[[ 9, 10, 11, 12]]])
★ Factors: Your turn
What behaviors do you observe in the examples below?
Example A
Example B
Example C